//
//  Utilities.m
//  iXNAT
//
//  Created by Daniel Blezek on 3/12/10.
//  Copyright 2010 Apple Inc. All rights reserved.
//

#import "Utilities.h"


@implementation Utilities
+(void)setActivityFrameLocation:(UIActivityIndicatorView*)activityIndicator withParent:(UIView*)view withAnimation:(BOOL)withAnimation {
  CGRect frame = activityIndicator.frame;
  CGRect viewFrame = view.frame;
  
  // Make the activity view centered.
  frame.size.width = 37;
  frame.size.height = 37;
  CGFloat half = 19;
  frame.origin.x = CGRectGetMidX(viewFrame) - half;
  frame.origin.y = CGRectGetMidY(viewFrame) - half;    
  
  if ( withAnimation ) {
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3];
  }
  [activityIndicator setFrame:frame];
  if ( withAnimation ) {
    [UIView commitAnimations];
  }
  
}

@end
